package com.lm.ffmpeg.example;

import com.lm.ffmpeg.util.FFmpegUtil;

public class FFmpegExample {

    public static void main(String[] args) throws Exception {

        String ffmpegPath = "F:\\ffmpeg\\bin\\ffmpeg.exe"; // Windows
        String inputVideo = "E:\\lk\\springboot-example\\lm-ffmpeg\\input.mp4";
        String outPutVideo = "E:\\lk\\springboot-example\\lm-ffmpeg\\output.avi";
// String ffmpegPath = "/usr/bin/ffmpeg";       // Linux
// String ffmpegPath = "/opt/homebrew/bin/ffmpeg"; // macOS (brew)

        String cmd = String.format("%s -i %s %s", ffmpegPath, inputVideo, outPutVideo);
        FFmpegUtil.executeCommand(cmd);

        cmd = "ffmpeg -i input.mp4 -ss 00:00:05 -vframes 1 output.jpg";
        FFmpegUtil.executeCommand(cmd);

        cmd = "ffmpeg -i input.mp4 -q:a 0 -map a output.mp3";
        FFmpegUtil.executeCommand(cmd);

//        FFmpegUtil.convertFilesInDirectory(inputVideo, outPutVideo, "avi");
    }
}
